#ifdef WIN32
#include <winsock2.h>
#endif
#include <iostream>
#include "miniutil/sysinfo.h"
#include "minitest/testcase.h"
#include "miniutil/thread.h"

using namespace miniutil;
using namespace miniutil::sys;

class sysinfotest:public testcase
{
public:
    virtual void test()
    {
        miniutil::m_uint64_t mem, vmem;
        int checkprocessid = sysinfo::get_process_id("msnmsgr.exe");
        std::cout<<"processor number:"<<sysinfo::get_processor_num()<<std::endl;
        std::cout<<"check process id:"<<checkprocessid<<std::endl;
        if(checkprocessid == 0)
            return;
        while(true)
        {
            std::cout<<"current process cpu usage:"<<sysinfo::get_process_cpu_usage(checkprocessid)<<std::endl;
            sysinfo::get_process_memory_usage(checkprocessid,
                &mem, &vmem);
            std::cout<<"current process mem usage:"<<mem<<" "<<vmem<<std::endl;
            
            //unsigned int result = 1;
            //for(unsigned int i=1; i<10000; i++)
            //    result = i*i*i*i*i*i;
            miniutil::thread::sleep(1000);
        }
    }
};

testcase * tsysinfotest = new sysinfotest();
